﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ThietBiSo.LinQDB;

namespace ThietBiSo.Models
{
    public class MFormLienHe
    {
        private _24hmuaonlineDataContext context = new _24hmuaonlineDataContext();

        public List<FormLienHe> FindAll()
        {
            var v = from f in context.FormLienHes orderby f.Id descending select f;
            return v.ToList();
        }
        public int GetTotalOrder()
        {
            return FindAll().Count();
        }
        public List<FormLienHe> GetList(int start, int offset)
        {
            var v = FindAll().Skip(start).Take(offset);
            return v.ToList();
        }
        public void Save(FormLienHe bv)
        {
            context.FormLienHes.InsertOnSubmit(bv);
            context.SubmitChanges();
        }
        public void Delete(int id)
        {
            var v = from p in context.FormLienHes
                    where p.Id.Equals(id)
                    select p;
            FormLienHe spdb = v.SingleOrDefault();
            context.FormLienHes.DeleteOnSubmit(spdb);
            context.SubmitChanges();
        }
        public void SaveChange()
        {
        }
        public int GetMax()
        {
            return (from t in context.FormLienHes
                    orderby t.Id descending
                    select t.Id).FirstOrDefault();
        }
    }
}